/*
 @描述：js使用的公共方法
 @创建时间：2015年7月16号 
 */

$(function(){
	/*防止别人在页面使用右键查看源码 */
	/*document.body.oncontextmenu=document.body.ondragstart= document.body.onselectstart=document.body.onbeforecopy=function(){return false;};
	document.body.onselect=document.body.oncopy=document.body.onmouseup=function(){document.selection.empty();};*/
	
	/*时间  */
	now = new Date(), hour = now.getHours();
	if (hour < 6) {
		$("#greetings").html("凌晨好！");
	} else if (hour < 9) {
		$("#greetings").html("早上好！");
	} else if (hour < 12) {
		$("#greetings").html("上午好！");
	} else if (hour < 14) {
		$("#greetings").html("中午好！");
	} else if (hour < 17) {
		$("#greetings").html("下午好！");
	} else if (hour < 19) {
		$("#greetings").html("傍晚好！");
	} else if (hour < 22) {
		$("#greetings").html("晚上好！");
	} else {
		$("#greetings").html("深里好！");
	}
	
	
//浮动搜索框拖动js
	var mFlag=false;
//鼠标与div左上角相对位置
	var divX='',divY='',
		pl=$(".v-play");
	pl.bind("click mousedown", function(e){
		e= e || window.event;
	if (e.type == 'click') {
		}else if(e.type == 'mousedown') {
		mFlag=true;
		divX =e.pageX - parseInt(pl.css("left"));
		divY =e.pageY - parseInt(pl.css("top"));
		}
	});
	$(document).mousemove(function(e){
		if(mFlag){
	//画出新坐标
		var pl=$(".v-play");
			le = e.pageX-divX,
			to = e.pageY-divY,
			winH = $(window).height(),
			winW = $(window).width(),
			cW = winW-pl.width()-20,
			cH = winH-pl.height()-20;
		if(le<0){
			le=0;
			}else if(le>cW){
				le=cW;
				}
		if(to<0){
			to=0;
			}else if(to>cH){
			to =cH;
			}
		pl.css({top:to,left:le});
		}
	}).mouseup(function(){
		mFlag=false;
	
		}); 
});

//浮动搜索款页面距离
$(window).scroll(function(){
	if($(this).scrollTop()>400){
		/* view_console(0);//隐藏控制器和列表 */
		$(".v-play").addClass("miniplayer");//先加个class让他缩小放到右下角
		}else{
			$(".v-play").removeClass("miniplayer");
			/* view_console(1);//显示控制器和列表 */
        }				
	});

//页面顶部时间
function getCurDate()
{
 var d = new Date();
 var week;
 switch (d.getDay()){
 case 1: week="星期一"; break;
 case 2: week="星期二"; break;
 case 3: week="星期三"; break;
 case 4: week="星期四"; break;
 case 5: week="星期五"; break;
 case 6: week="星期六"; break;
 default: week="星期天";
 }
 var years = d.getFullYear();
 var month = add_zero(d.getMonth()+1);
 var days = add_zero(d.getDate());
 var hours = add_zero(d.getHours());
 var minutes = add_zero(d.getMinutes());
 var seconds=add_zero(d.getSeconds());
 var ndate = years+"年"+month+"月"+days+"日 "+hours+":"+minutes+":"+seconds+" "+week;
 var divT=document.getElementById("divT"); 
 divT.innerHTML= ndate;
}
 
function add_zero(temp)
{
 if(temp<10) return "0"+temp;
 else return temp;
}
 
setInterval("getCurDate()",100);
